package com.qding.park.common.utils.rchl;



import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

public class RchlExceptionUtil {
	public static String getStackMessage(Throwable e){
		String mess = null;
		ByteArrayOutputStream bos =null;
		PrintWriter writer = null;
		try {
			bos=new ByteArrayOutputStream();
			writer=new PrintWriter(bos);
			Exception realException=(Exception)e;
			realException.printStackTrace(writer);
			writer.println();
			writer.flush();
			writer.close();
			mess=bos.toString();
		} catch (Exception e1) {
			e1.printStackTrace();
		}
		finally{
			writer.close();
			closeStream(null,bos);
		}
		return mess;
	}
	
	public static void closeStream(InputStream is,OutputStream os){
		if(is!=null){
			try {
				is.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
		if(os!=null){
			try {
				os.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	

}
